function uptime()
{	
	$pc = New-Object System.Diagnostics.PerformanceCounter("System", "System Up Time")
	$upSeconds = 0.0
	$totalSleepTime = 0
	$sleepDuration = 100
	
	do
	{
		$upSeconds = $pc.NextValue()
		$totalSleepTime = $totalSleepTime + $sleepDuration
		sleep -m $sleepDuration
	}
	while(($upSeconds -eq 0) -or ($totalTime -eq 1000))
	
	$pc.Close()
	
	$upMinutes = [Math]::Floor($upSeconds / 60)
	$upHours = [Math]::Floor($upMinutes / 60)
	$remainingMinutes = $upMinutes % 60
	
	[string]::Format("{0:0} Hours {1:0} Minutes", $upHours, $remainingMinutes)
}

function mf($path)
{
	new-item -type file $path
}

function fs()
{
	$disks = Get-WmiObject -ComputerName "." -Class Win32_LogicalDisk
	
	foreach ($disk in $disks)
	{
		if ($disk.DriveType -eq 3)
		{
			[string]::Format("Drive Letter: {0:N0}", $disk.DeviceID)
			[string]::Format("Volume Name:  {0:N0}", $disk.VolumeName)
			[string]::Format("Total Size:   {0:N0} MB", $disk.Size/(1024*1024))
			[string]::Format("Free Space:   {0:N0} MB", $disk.FreeSpace/(1024*1024))
			echo ""
		}
	}
}

function getweb($url)
{
	$wc = New-Object System.Net.WebClient
	$wc.DownloadString($url)
}

function getfile($url, $filename)
{
	$wc = New-Object System.Net.WebClient
	
	Register-ObjectEvent -InputObject $wc -EventName DownloadProgressChanged -SourceIdentifier WebClient.DownloadProgressChanged -Action { Write-Progress -Activity "Downloading: $($EventArgs.ProgressPercentage)% Completed" -Status $url -PercentComplete $EventArgs.ProgressPercentage; }
	Register-ObjectEvent -InputObject $wc -EventName DownloadFileCompleted -SourceIdentifier WebClient.DownloadFileComplete -Action { Write-Host "Download Complete - $filename"; Unregister-Event -SourceIdentifier WebClient.DownloadProgressChanged; Unregister-Event -SourceIdentifier WebClient.DownloadFileComplete; }
	
	try
    {
		$wc.DownloadFileAsync($url, $filename)
    }
    catch [System.Net.WebException]
    {
        Write-Host("Cannot download $url")
    } 
	finally
	{	
		$wc.Dispose()
	}
}

function weather($city='Karachi', $country='Pakistan')
{
	$uri = "http://www.webservicex.com/globalweather.asmx?WSDL"
	$weather = New-WebServiceProxy -uri $uri

	[string]::Format("Source		 : {0}", $uri)
	[string]::Format("City   		 : {0}", $city)
	[string]::Format("Country		 : {0}", $country)
	
	$xml = $weather.GetWeather($city, $country)
	
	if ($xml -eq "Data Not Found")
	{
		Write-Host "`nCould not find weather information for the specified location"
	}
	else
	{
		([xml]$xml).CurrentWeather
	}
}

function utc()
{
	[System.DateTime]::Now.ToUniversalTime()
}

function pow($n, $m)
{
	[Math]::Pow($n, $m)
}

function abs($num)
{
	[Math]::Abs($num)
}


function sqr($n)
{
	[Math]::Pow($n, 2)
}

function sqrt($n)
{
	[Math]::Sqrt($n)
}

function log($n)
{
	[Math]::Log10($n)
}

function ln($n)
{
	[Math]::Log($n)
}